from control.server import server

class Runtime:
    def __init__(self):
        self.version = "0.0.1"
        self.app_task = {}

    def get_app_status(self, app_key):
        """获取应用状态"""
        from service.app import app_service
        
        # 检查进程是否存在
        if app_key not in app_service.app_tokens:
            return "stopped"
            
        # 获取token
        token = app_service.app_tokens[app_key]
        
        # 检查WebSocket连接状态
        if server.is_app_running(token):
            return "running"
        
        return "error"  # WebSocket连接断开但进程可能还在运行

runtime = Runtime()
